package com.sl.biz.modular.cdc.controller;

import com.sl.biz.modular.cdc.controller.domain.vo.CdcConfigVO;
import com.sl.biz.modular.cdc.dao.domain.entity.CdcConfigDO;
import com.sl.biz.modular.cdc.service.CdcBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cdc")
@RequiredArgsConstructor
public class CdcController {

    private final CdcBizService cdcBizService;


    @PostMapping("/list")
    public List<CdcConfigVO> list(@RequestBody CdcConfigDO jobConfigDO) {
        return cdcBizService.list(jobConfigDO);
    }

    @PostMapping("/get_by_id")
    public CdcConfigDO getById(@RequestBody CdcConfigDO cdcConfigDO) {
        return cdcBizService.getById(cdcConfigDO);
    }

    @PostMapping("/remove_by_id")
    public Boolean removeById(@RequestBody CdcConfigDO cdcConfigDO) {
        return cdcBizService.removeById(cdcConfigDO);
    }

    @PostMapping("/save")
    public Boolean save(@RequestBody CdcConfigDO cdcConfigDO) {
        return cdcBizService.save(cdcConfigDO);
    }

    @PostMapping("/stop")
    public Boolean stop(@RequestBody CdcConfigDO jobAddRequest) {
        return cdcBizService.stop(jobAddRequest);
    }

    @PostMapping("/start")
    public Boolean start(@RequestBody CdcConfigDO cdcConfigDO) {
        return cdcBizService.start(cdcConfigDO);
    }

    @PostMapping("/set_status_flag")
    public Boolean setStatusFlag(@RequestBody @Validated CdcConfigDO assertUserUse) {
        return cdcBizService.setStatusFlag(assertUserUse);
    }

}
